package net.qunzhi.modules.app.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.qunzhi.common.utils.PageUtils;
import net.qunzhi.common.utils.R;
import net.qunzhi.modules.app.annotation.Login;
import net.qunzhi.modules.app.utils.JwtUtils;
import net.qunzhi.modules.cms.entity.TbAlarmRecordEntity;
import net.qunzhi.modules.cms.query.AlarmRecordRecordQuery;
import net.qunzhi.modules.cms.service.TbAlarmRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 监控报警记录
 *
 * @author zjr
 * @date 2021-11-03 11:50:15
 */
@Api(tags = "app监控报警记录相关")
@RestController
@RequestMapping("app/tbAlarmRecord")
public class AppAlarmRecordController {
    @Autowired
    private TbAlarmRecordService tbAlarmRecordService;
    @Autowired
    private JwtUtils jwtUtils;

    /**
     * 列表
     */
    @ApiOperation("列表")
    @GetMapping("/list")
    @Login
    public R list(AlarmRecordRecordQuery query){
        PageUtils page = tbAlarmRecordService.queryPage(query);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("信息")
    @GetMapping("/info/{id}")
    @Login
    public R info(@PathVariable("id") Integer id, HttpServletRequest request){
		TbAlarmRecordEntity tbAlarmRecord = tbAlarmRecordService.getInfoById(id, Long.parseLong(jwtUtils.getClaimByToken(request.getHeader(jwtUtils.getHeader())).getSubject()));

        return R.ok().put("tbAlarmRecord", tbAlarmRecord);
    }

}
